package vip.xiaonuo.smzq.modular.synchronize.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import vip.xiaonuo.smzq.modular.synchronize.entity.TableFields;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vip.xiaonuo.smzq.modular.synchronize.entity.vo.FieldVo;

import java.util.List;
import java.util.Map;

/**
 * 表字段管理表 Mapper
 *
 * @author sqq
 * @since 2025-02-21
 */
@Mapper
public interface TableFieldsMapper extends BaseMapper<TableFields> {

    /**
     * 获取表名
     * @return
     */
    @Select("select table_name from sys_table_fields group by table_name ")
    List<String> getTables();

    /**
     * 删除数据
     * @param delSql
     */
    @Delete("${sql}")
    Integer delData(String delSql);

    /**
     * 获取字段 及类型
     * @param table
     * @return
     */
    @Select("select field,data_type from sys_table_fields where table_name=#{table} ")
    List<FieldVo> getField(String table);

    /**
     * 插入数据
     * @param sql
     */
    @Select("${sql}")
    void insertData(String sql);

    /**
     * 获取表数据
     * @param tableName
     * @param nd
     * @return
     */
    @Select("select * from ${tableName} where nd=#{nd}")
    List<Map> getTableDataList(@Param("tableName") String tableName, @Param("nd") int nd);
}
